package zuoye31dao40;

import java.util.Arrays;

public class lx36 {
	public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5, 6, 7};
        int m = 3;
        shiftArray(arr, m);
        System.out.println(Arrays.toString(arr));
    }

    public static void shiftArray(int[] arr, int m) {
        int n = arr.length;
        m = m % n; 

        reverse(arr, 0, n - 1);
        reverse(arr, 0, m - 1);
        reverse(arr, m, n - 1);
    }

    public static void reverse(int[] arr, int start, int end) {
        while (start < end) {
            int temp = arr[start];
            arr[start] = arr[end];
            arr[end] = temp;
            start++;
            end--;
        }
    }
}
